package com.frank.wcld.zfwt.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.wcld.zfwt.domain.WcldZfwt;
import com.frank.wcld.zfwt.service.IWcldZfwtService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 纪律作风督查问题Controller
 * 
 * @author frank
 * @date 2025-04-07
 */
@Controller
@RequestMapping("/wcld/zfwt")
public class WcldZfwtController extends BaseController
{
    private String prefix = "wcld/zfwt";

    @Autowired
    private IWcldZfwtService wcldZfwtService;

    @RequiresPermissions("wcld:zfwt:view")
    @GetMapping()
    public String 纪律作风督查问题()
    {
        return prefix + "/zfwt";
    }

    /**
     * 查询纪律作风督查问题列表
     */
    @RequiresPermissions("wcld:zfwt:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WcldZfwt wcldZfwt)
    {
        wcldZfwt.setCreateBy(getLoginName());
        startPage();
        List<WcldZfwt> list = wcldZfwtService.selectWcldZfwtList(wcldZfwt);
        return getDataTable(list);
    }

    /**
     * 导出纪律作风督查问题列表
     */
    @RequiresPermissions("wcld:zfwt:export")
    @Log(title = "纪律作风督查问题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WcldZfwt wcldZfwt)
    {
        List<WcldZfwt> list = wcldZfwtService.selectWcldZfwtList(wcldZfwt);
        ExcelUtil<WcldZfwt> util = new ExcelUtil<WcldZfwt>(WcldZfwt.class);
        return util.exportExcel(list, "纪律作风督查问题数据");
    }

    /**
     * 新增纪律作风督查问题
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存纪律作风督查问题
     */
    @RequiresPermissions("wcld:zfwt:add")
    @Log(title = "纪律作风督查问题", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WcldZfwt wcldZfwt)
    {
        wcldZfwt.setCreateBy(getLoginName());
        return toAjax(wcldZfwtService.insertWcldZfwt(wcldZfwt));
    }

    /**
     * 修改纪律作风督查问题
     */
    @RequiresPermissions("wcld:zfwt:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WcldZfwt wcldZfwt = wcldZfwtService.selectWcldZfwtById(id);
        mmap.put("wcldZfwt", wcldZfwt);
        return prefix + "/edit";
    }

    /**
     * 修改保存纪律作风督查问题
     */
    @RequiresPermissions("wcld:zfwt:edit")
    @Log(title = "纪律作风督查问题", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WcldZfwt wcldZfwt)
    {
        wcldZfwt.setUpdateBy(getLoginName());
        return toAjax(wcldZfwtService.updateWcldZfwt(wcldZfwt));
    }

    /**
     * 删除纪律作风督查问题
     */
    @RequiresPermissions("wcld:zfwt:remove")
    @Log(title = "纪律作风督查问题", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wcldZfwtService.deleteWcldZfwtByIds(ids));
    }
}
